package com.yanqu.road.server.cmd.activity.douluoshrek;

import com.yanqu.road.pb.activity.DouLuoShrekProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.shrek.DouLuoShrekModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_DOULUOSHREK_LEAVE, desc = "")
public class ShrekLeaveSceneCmd extends AbstractCommand {

    int activityId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        DouLuoShrekProto.LeaveSceneReqMsg reqMsg = DouLuoShrekProto.LeaveSceneReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        player.getModule(DouLuoShrekModule.class).leaveScene(activityId);
    }

    @Override
    public void sendData(GamePlayer player) {
        DouLuoShrekProto.LeaveSceneRespMsg.Builder respMsg = DouLuoShrekProto.LeaveSceneRespMsg.newBuilder();
        respMsg.setRet(0);
        player.sendPacket(Protocol.U_DOULUOSHREK_LEAVE_SCENE, respMsg);
    }
}
